package com.lzw.breezeNovel.webApp.controller.comic;

import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.model.entity.query.PaginationResultQuery;
import com.lzw.breezeNovel.webApp.service.comic.ComicService;
import com.lzw.breezeNovel.webApp.vo.comic.ComicVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.comic
 * @date 2025/3/15
 * @description 漫画的控制类
 */
@RestController
@RequestMapping("/app/comic")
@SuppressWarnings("all")
public class ComicController {

    /**
     * 注入service
     */
    @Autowired
    private ComicService comicService;

    /**
     * 分页获取排行榜信息
     */
    @RequestMapping("/rank")
    public Result<PaginationResultQuery<ComicVo>> getRank(@RequestParam Integer pageNo, @RequestParam Integer size,@RequestParam String like){
        PaginationResultQuery<ComicVo> comicVos = comicService.getRank(pageNo,size,like);
        return Result.ok(comicVos);
    }

    /**
     * 分页获取会员漫画
     */
    @RequestMapping("/vip")
    public Result<PaginationResultQuery<ComicVo>> getVip(@RequestParam Integer pageNo, @RequestParam Integer size){
        PaginationResultQuery<ComicVo> comicVos = comicService.getVip(pageNo,size);
        return Result.ok(comicVos);
    }

    /**
     * 分页获取免费漫画
     */
    @RequestMapping("/free")
    public Result<PaginationResultQuery<ComicVo>> getFree(@RequestParam Integer pageNo, @RequestParam Integer size){
        PaginationResultQuery<ComicVo> comicVos = comicService.getFree(pageNo,size);
        return Result.ok(comicVos);
    }

    /**
     * 获取所有的新书
     */
    @RequestMapping("/new")
    public Result<PaginationResultQuery<ComicVo>> getNew(@RequestParam Integer pageNo, @RequestParam Integer size) {
        PaginationResultQuery<ComicVo> comicVos = comicService.getNew(pageNo, size);
        return Result.ok(comicVos);
    }

    /**
     * 进行漫画搜索
     */
    @RequestMapping("/search")
    public Result<PaginationResultQuery<ComicVo>> search(@RequestParam Integer pageNo, @RequestParam Integer size,@RequestParam String keyword){
        PaginationResultQuery<ComicVo> comicVos = comicService.search(pageNo,size,keyword);
        return Result.ok(comicVos);
    }

    /**
     * 根据类型获取相关的漫画
     */
    @RequestMapping("/type")
    public Result<PaginationResultQuery<ComicVo>> getType(@RequestParam String type,@RequestParam Integer pageNo, @RequestParam Integer size,@RequestParam Integer id){
        PaginationResultQuery<ComicVo> comicVos = comicService.getType(type,pageNo,size,id);
        return Result.ok(comicVos);
    }

    /**
     * 保存浏览量
     */
    @RequestMapping("/save")
    public Result save(@RequestParam Long comicId){
        comicService.save(comicId);
        return Result.ok();
    }


}
